home *** CD-ROM | disk | FTP | other *** search
/ 3D Images / 3D Images.iso / programs / amiga / batchfactory / scripts / imagefx / image-fx_moving_spotlights < prev   
Encoding:
Text File  |  1995-01-12  |  8.5 KB  |  336 lines

  1. /* 
  2.                         IMAGE FX MOVING SPOTLIGHTS
  3.                                By J.L. White
  4.                           ©1994 Merlin's Software
  5.  
  6.           Load Image & Add A Moving SpotLight To Series Of Frames
  7.                               ImageFX Script
  8.                       Requires The Rexxarplib.library
  9.  
  10.  Batch Factory Batch Conversion Scripts are basically Arexx scripts that
  11. allow you to pass certain parameters to the external program you wish
  12. to use to convert the images from one format to another. You can pass
  13. five different strings from Batch Factory to the script by using the
  14. following commands:
  15.  
  16. $N = This will pass the current selected filename.
  17. $P = This will tell Batch Factory to ask for a path to save new frames to.
  18. $# = This will pass the current frame number in the script.
  19. $T = This will pass the total number of frames in the script.
  20. $A = This will pass an offset number to be used to save frames with.
  21.  
  22. NOTE: The following line is required to work as a Batch Factory Script:
  23.  
  24. PARSE=$N $P $# $A $T
  25.  
  26. */
  27.  
  28. if ~show('l', "rexxarplib.library") then do
  29.     check = addlib('rexxsupport.library',0,-30,0) 
  30.     check = addlib('rexxarplib.library',0,-30,0)   
  31.     end
  32. options results
  33. call Locate_ImageFX
  34. address "IMAGEFX.1"
  35. arg InPic OutPic FrameNum AddNum TotalNum
  36. SaveNum = FrameNum + AddNum
  37. if FrameNum = 1 then do
  38.     Top = 170
  39.     Height = ScreenRows("Batch")
  40.     if Height < 400 then Top = 70
  41.     address "AREXX"
  42.     ScreenToFront("Batch")
  43.     call GetMotionPath
  44.     address "IMAGEFX.1"
  45.     ScreenToFront
  46.     RequestSlider '"Enter Amount To Darken Image!"' 1 127 75
  47.     Answer = -Result
  48.     RequestSlider '"Enter Radius Of SpotLight!"' 1 200 50
  49.     Answer2 = Result
  50.     RequestSlider '"Enter Amount To Feather SpotLights!"' 1 50 5
  51.     Answer3 = Result
  52.     RequestSlider '"Enter Number Of SpotLights!"' 1 2 1
  53.     Answer4 = Result
  54.     call open TempFile,"Ram:IFMS",W
  55.     call writeln TempFile,Answer
  56.     call writeln TempFile,Answer2
  57.     call writeln TempFile,Answer3
  58.     call writeln TempFile,Answer4
  59.     call close TempFile
  60.     end
  61. else do
  62.     call open TempFile,"Ram:IFMS",R
  63.     line = readln(TempFile)
  64.     parse var line Answer
  65.     line = readln(TempFile)
  66.     parse var line Answer2
  67.     line = readln(TempFile)
  68.     parse var line Answer3
  69.     line = readln(TempFile)
  70.     parse var line Answer4
  71.     call close TempFile
  72.     end
  73.  
  74. address "IMAGEFX.1"
  75. DrawMode Normal
  76. ActiveColor 1
  77. LoadBuffer InPic Force Smooth
  78. Undo Off
  79. Redraw Off
  80. GetMain
  81. parse var result Name Width Height Blah
  82. call GetXYCords
  83. Buffer2Swap
  84. ClearBuffer Force 0 0 0
  85. AlphaChannel Off
  86. EdgeMode FeatherOut Answer3
  87. FilledOval X Y Answer2 Answer2
  88. if Answer4 = 2 then
  89.     FilledOval Width-X Y Answer2 Answer2
  90. EdgeMode Normal
  91. Buffer2Alpha
  92. Swap
  93. Buffer2Swap
  94. Brightness Answer
  95. AlphaChannel FRISKET
  96. Merge 100 Alpha
  97. Redraw On
  98. Undo On
  99. if OutPic = "SAME" then
  100.     SaveBufferAs ILBM InPic
  101. else
  102.     SaveBufferAs ILBM OutPic""right(SaveNum,3,'0')
  103. if FrameNum = TotalNum then do
  104.     address command "Delete >NIL: Ram:IFMS"
  105.     address command "Delete >NIL: RAM:TimeLine.File"
  106.         end
  107. exit
  108.  
  109. Locate_ImageFX:
  110.     if (POS('IMAGEFX.1',SHOW('Ports')) = 0)
  111.     then do
  112.         address command 'run < nil: > nil: IMAGEFX:ImageFX'
  113.         address command 'wait 7'
  114.     end
  115. return
  116.  
  117.  
  118.  
  119. GetMotionPath:
  120.     address arexx "'call CreateHost(BFHOST,BFPORT,"MOUSESCREEN")'"
  121.     call Delay(30)
  122.     Width = 320
  123.     Height = 200
  124.     XOff = 0
  125.     YOff = 0
  126.     call Request(190,(Top+6)-14,"Select Screen Width Of Images!",,"HIRES","LORES","Batch")
  127.     if result = "OKAY" then do
  128.         Settings = "HIRES"
  129.         Width = 640
  130.         end
  131.     else Settings = ""
  132.     call Request(180,(Top+6)-14,"Select Screen Height Of Images!",,"LACE","NOLACE","Batch")
  133.     if result = "OKAY" then do
  134.         Settings = Settings"+LACE"
  135.         Height = 400
  136.         end
  137.     if Height = 400 & Width = 640 then do
  138.         call Request(185,(Top+6)-14," Select Over Scan Option!",,"OVERSCAN","REGULAR","Batch")
  139.         if result = "OKAY" then do
  140.             Settings = Settings"+OVERSCAN+AUTOSCROLL"
  141.             call Request(180,(Top+6)-14," Enter New Screen Width!","736","OKAY",,"Batch")
  142.             Width = result
  143.             XOff = 640 - Width
  144.             call Request(180,(Top+6)-14," Enter New Screen Height!","480","OKAY",,"Batch")
  145.             Height = result
  146.             YOff = 400 - Height
  147.             end
  148.         end
  149.     result = OpenScreen(YOff,3,Settings,'','MOUSESCREEN',,Width,Height,XOff)
  150.     Height = ScreenRows("MOUSESCREEN")
  151.     Width = ScreenCols("MOUSESCREEN")
  152.     idcmp     = 'CLOSEWINDOW+GADGETUP+MOUSEMOVE+MOUSEBUTTONS'
  153.     flags     = 'BORDERLESS+BACKDROP+REPORTMOUSE'
  154.     call OpenWindow(BFHOST, 0, 0, Width, Height, idcmp, flags, )
  155.     call ShowTitle("MOUSESCREEN",0)
  156.     call ModifyHost(BFHOST, MOUSEMOVE, "%l %x %y")
  157.     call ModifyHost(BFHOST, MOUSEBUTTONS, "%b %x %y")
  158.     call AddGadget(BFHOST,15,8,"OK"," OKAY ","OK")
  159.     SetAPen(BFHOST,1)
  160.     SetDrMd(BFHOST,JAM2)
  161.     call Move(BFHOST,0,Height%2)  
  162.     call Draw(BFHOST,Width,Height%2)
  163.     call Move(BFHOST,Width%2,0)  
  164.     call Draw(BFHOST,Width%2,Height)
  165.     call Move(BFHOST,0,0)  
  166.     call Draw(BFHOST,0,Height)
  167.     call Move(BFHOST,0,0)  
  168.     call Draw(BFHOST,Width,0)
  169.     call Move(BFHOST,Width-1,0)  
  170.     call Draw(BFHOST,Width-1,Height)
  171.     call Move(BFHOST,0,Height-1)  
  172.     call Draw(BFHOST,Width,Height-1)
  173.     call ActivateWindow(BFHOST)
  174.     call Request((Width-304)%2,(Height-60)%2,"Draw Line By Moving The Mouse.\Click Mouse To Change Direction.\Click OKAY When You Are Done.",,"OK",,"MOUSESCREEN")
  175.     xpos = 0
  176.     ypos = 0
  177.     xm = -1
  178.     ym = -1
  179.     quitflag = 0
  180.     Start = 0
  181.     i = 0
  182.     call openport(BFPORT)
  183.     do until quitflag = 1 
  184.       call waitpkt(BFPORT)
  185.       packet = getpkt(BFPORT)
  186.       if packet ~= null() then do
  187.         cmd = getarg(packet) 
  188.         call reply(packet,0)
  189.         if cmd = OK then do
  190.            call Move(BFHOST,xpos,ypos)
  191.            call Draw(BFHOST,xm,ym)
  192.            call ImageOK
  193.            end
  194.        else do
  195.              parse var cmd button x y
  196.              if (button == 'MOUSEMOVE' & Start > 0) then do
  197.             call Move(BFHOST,xpos,ypos)
  198.                 call Draw(BFHOST,xm,ym)
  199.                 xm = x
  200.             ym = y
  201.             call SetDrMd(BFHOST,COMPLEMENT)
  202.             call Move(BFHOST,xpos,ypos)  
  203.             call Draw(BFHOST,xm,ym)
  204.              end
  205.              else if button == 'SELECTDOWN' then do
  206.             Start = Start + 1
  207.             if Start = 1 then do
  208.             xpos = x
  209.             ypos = y
  210.             i = i + 1
  211.             XPosition.i = xpos
  212.             YPosition.i = ypos
  213.                     xm = x
  214.                   ym = y
  215.                      call SetDrMd(BFHOST,COMPLEMENT)
  216.                 call Move(BFHOST,xpos,ypos)  
  217.                 call Draw(BFHOST,xm,ym)
  218.             call PrintText
  219.             end
  220.              end
  221.          else if(button == 'SELECTUP') then do 
  222.             i = i + 1
  223.             if x = Width - 1 then x = Width
  224.             if y = Height -1 then y = Height
  225.             XPosition.i = x
  226.             YPosition.i = y
  227.             call PrintText
  228.                    xpos = x
  229.                ypos = y
  230.             end
  231.              end
  232.       end
  233.    end
  234.    call CloseWindow(BFHOST)
  235.    result = CloseScreen('MOUSESCREEN')
  236.    call ClosePort(BFPORT)
  237. return
  238.  
  239. AbortIt:
  240.     call CloseWindow(BFHOST)
  241.     result = CloseScreen('MOUSESCREEN')
  242.     call ClosePort(BFPORT)
  243.     call Request(200,(Top+36)-14,"Process Has Been Cancelled\Please Abort Script!!",,"OK",,"Batch")
  244.     address command "Wait 2"
  245.     exit
  246. return
  247.     
  248.  
  249. ImageOK:
  250.     call Request((Width-232)/2,(Height-70)/2,"Is The Time Line Correct?",,"OK","CANCEL","MOUSESCREEN")
  251.     if result = "OKAY" then do
  252.         quitflag = 1
  253.     call open OutData,"RAM:TimeLine.File",'W'
  254.     do x = 2 to i
  255.     call writeln OutData,XPosition.x""YPosition.x
  256.     end
  257.     call close OutData
  258.         end
  259.     else do
  260.         xpos = 0
  261.         ypos = 0
  262.         xm = -1
  263.         ym = -1
  264.         Start = 0
  265.         i = 0
  266.         call BackFill(BFHOST)
  267.         call RefreshGadgets(BFHOST)
  268.         SetAPen(BFHOST,1)
  269.         SetDrMd(BFHOST,JAM2)
  270.         call Move(BFHOST,0,Height/2)  
  271.         call Draw(BFHOST,Width,Height/2)
  272.         call Move(BFHOST,Width/2,0)  
  273.         call Draw(BFHOST,Width/2,Height)
  274.         call Move(BFHOST,0,0)  
  275.         call Draw(BFHOST,0,Height)
  276.         call Move(BFHOST,0,0)  
  277.         call Draw(BFHOST,Width,0)
  278.         call Move(BFHOST,Width-1,0)  
  279.         call Draw(BFHOST,Width-1,Height)
  280.         call Move(BFHOST,0,Height-1)  
  281.         call Draw(BFHOST,Width,Height-1)
  282.         end
  283. return
  284.  
  285. PrintText:
  286.     SetAPen(BFHOST,1)
  287.     SetDrMd(BFHOST,JAM2)
  288.     call Move(BFHOST,85,16)
  289.     YText = strip(y)
  290.     call Text(BFHOST,"Key Frame #"right(i-1,3,'0')" X="right(x,3,'0')"  Y="right(YText,3,'0'))
  291.     SetAPen(BFHOST,2)
  292.     SetDrMd(BFHOST,JAM1)
  293. return
  294.  
  295.  
  296. GetXYCords:
  297.     i = 0
  298.     call open KeyData,"RAM:TimeLine.File",'R'
  299.     do until eof(KeyData)
  300.         i = i + 1
  301.         line = readln(KeyData)
  302.         parse var line XCord.i' 'YCord.i
  303.         end
  304.     call close KeyData
  305.     TotalKey = i-2
  306.     NumKey = (TotalNum/TotalKey)
  307.     FirstNum = ((NumKey - (NumKey-(FrameNum-1)))%NumKey)+1
  308.     SecNum = FirstNum+1
  309.     if FirstNum = TotalKey then do
  310.         NumKey = NumKey - 1
  311.         NewNum = (((FrameNum-((FirstNum-1)*NumKey)))-(TotalKey-1))
  312.         end
  313.     else 
  314.         NewNum = ((FrameNum-((FirstNum-1)*NumKey)))
  315.     X1 = XCord.FirstNum
  316.     Y1 = YCord.FirstNum
  317.     X2 = XCord.SecNum
  318.     Y2 = YCord.SecNum
  319.     if X2 < X1 then do
  320.         DiffX = -((X1-X2)/(NumKey))
  321.         end
  322.     else do
  323.         DiffX = ((X2-X1)/(NumKey))
  324.         end
  325.     if Y2 < Y1 then do
  326.         DiffY = -((Y1-Y2)/(NumKey))
  327.         end
  328.     else do
  329.         DiffY = ((Y2-Y1)/(NumKey))
  330.         end
  331.     X = (X1 + (DiffX*NewNum))-DiffX
  332.     Y = (Y1 + (DiffY*NewNum))-DiffY
  333.     X = X % 1
  334.     Y = Y % 1
  335. return
  336.